﻿using System;
using System.Xml;
using System.Xml.Linq;
using Xom.Elements;

namespace Xom
{
    public interface IXmlObjectMapper
    {
        /// <summary>
        /// Create a XOM Object from a Fle.
        /// </summary>
        /// <param name="filename">A URI string that references the file to load into a new XOM Object.</param>
        /// <param name="type">The type of the object that this XOM can serialize.</param>
        /// <returns>An XOM Object that contains the contents of the specified file.</returns>
        object Load(string filename, Type type);

        /// <summary>
        /// Create a XOM Object from a specified XDocument.
        /// </summary>
        /// <param name="xmlfile">A XDocument that references the file to load into a new XOM Object.</param>
        /// <param name="type">The type of the object that this XOM can serialize.</param>
        /// <returns>An XOM Object that contains the contents of the specified file.</returns>
        object Load(XDocument xmlfile, Type type);

        /// <summary>
        /// Create a XOM Object from a specified XmlDocument.
        /// </summary>
        /// <param name="xmlNode">A XmlDocument that references the file to load into a new XOM Object.</param>
        /// <param name="type">The type of the object that this XOM can serialize.</param>
        /// <returns>An XOM Object that contains the contents of the specified file.</returns>
        object Load(XmlNode xmlNode, Type type);

        /// <summary>
        /// Save the loaded XML document to the specified file.
        /// </summary>
        /// <param name="filename">The location of the file where you want to save the document.</param>
        void Save(string filename);

        /// <summary>
        /// Serialize the loaded XML document to a String.
        /// </summary>
        /// <returns>A String that the XML will be written to.</returns>
        string Save();

        /// <summary>
        /// Creates a new XOM Object from a string.
        /// </summary>
        /// <param name="text">A string that contains XML.</param>
        /// <param name="type">The type of the object that this XOM can serialize.</param>
        /// <returns>An XOM Object populated from the string that contains XML.</returns>
        object Parse(string text, Type type);

        /// <summary>
        /// Create a new XML document from a specified XOM Object.
        /// </summary>
        /// <param name="element">An XOM Object that contains the contents for the specified file.</param>
        /// <param name="filename">The location of the file where you want to save the document.</param>
        /// <param name="rootNodeName">The name of the root XML node.</param>
        void Create(IXomElement element, string filename, string rootNodeName);

        /// <summary>
        /// Creates a new XElement from a specified Object
        /// </summary>
        /// <param name="element">An XOM Object that contains the contents for the new XElement.</param>
        /// <param name="rootNodeName">The name of the root XML node.</param>
        /// <returns>A XElement that contains the contents of the specified object</returns>
        XElement CreateElement(IXomElement element, string rootNodeName);

        /// <summary>
        /// Create a new XDocument from a specified XOM Object.
        /// </summary>
        /// <param name="element">An XOM Object that contains the contents for the specified file.</param>
        /// <param name="rootNodeName">The name of the root XML node.</param>
        /// <returns>A XDocument that contains the contents of the specified XOM Object.</returns>
        XDocument Create(IXomElement element, string rootNodeName);
    }
}
